package com.engine.devcom.mode.util;

import org.apache.commons.lang.StringUtils;
import weaver.conn.RecordSet;
import weaver.general.Util;
import weaver.workflow.workflow.WorkflowBillComInfo;

/**
 * @author : hmy
 * @since : 2025/6/6
 */
public class WorkflowUtils {


    public static String getTableName(String workflowId) {
        String tableName = "";
        if (StringUtils.isBlank(workflowId)) {
            return tableName;
        }
        RecordSet rs = new RecordSet();
        String isBillSql = " select isbill,formid from  workflow_base where id = ? ";
        rs.executeQuery(isBillSql, workflowId);
        int isbill = 1;
        String formid = "";
        if (rs.next()) {
            isbill = Util.getIntValue(rs.getString("isbill"), 1);
            formid = Util.null2String(rs.getString("formid"));
        }
        if (isbill == 0) {
            tableName = "workflow_form";
        } else if (isbill == 1) {
            WorkflowBillComInfo billComInfo = new WorkflowBillComInfo();
            tableName = billComInfo.getTablename(formid);
            if (StringUtils.isBlank(tableName)) {
                String namesql = " select tableName from workflow_bill where id=? ";
                rs.executeQuery(namesql, formid);
                if (rs.next()) tableName = Util.null2String(rs.getString("tableName"));
            }
        }
        return tableName;
    }
}
